<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/common/common.jspf" %>
    <style type="text/css">
        .col-sm-3 {
            width: 15%;
            float: left;
            text-align: right;
        }

        .col-sm-9 {
            width: 85%;
            float: left;
            text-align: left;
        }

        label[class^="btn btn-default"] {
            margin-top: -4px;
        }
    </style>
</head>
<body>
<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
<form id="form" name="form" class="form-horizontal" method="post" action="${ctx}/dsg/commission/addEntity.shtml">
    <section class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">会员等级</label>
                </div>
                <div class="col-sm-9">
                    <input type="text" class="form-control" placeholder="请输入会员等级" id="grade" name="dsgCommissionInfoFormMap.grade" style="width: 30%;">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">类型名称</label>
                </div>
                <div class="col-sm-9">
                    <input type="text" class="form-control" placeholder="类型名称" id="name" name="dsgCommissionInfoFormMap.name" style="width: 30%;">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">一级代理佣金(%)</label>
                </div>
                <div class="col-sm-9">
                    <input type="text" class="form-control" placeholder="一级代理佣金" id="commission_1" name="dsgCommissionInfoFormMap.commission_1" style="width: 30%;">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">二级代理佣金(%)</label>
                </div>
                <div class="col-sm-9">
                    <input type="text" class="form-control" placeholder="二级代理佣金" id="commission_2" name="dsgCommissionInfoFormMap.commission_2" style="width: 30%;">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-3">
                    <label class="control-label">三级代理佣金(%)</label>
                </div>
                <div class="col-sm-9">
                    <input type="text" class="form-control" placeholder="三级代理佣金" id="commission_3" name="dsgCommissionInfoFormMap.commission_3" style="width: 30%;">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
        </div>
        <footer class="panel-footer text-right bg-light lter">
            <button type="submit" class="btn btn-success btn-s-xs">提交</button>
        </footer>
    </section>
</form>
<script type="application/javascript">
    $(function () {
        $("form").validate({
            submitHandler: function (form) { // 必须写在验证前面，否则无法ajax提交
                ly.ajaxSubmit(form, { // 验证新增是否成功
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if (data == "success") {
                            layer.confirm('添加成功!是否关闭窗口?', function (index) {
                                parent.grid.loadData();
                                parent.layer.close(parent.pageii);
                                return false;
                            });
                            $("#form")[0].reset();
                        } else {
                            layer.msg('添加失败！');
                        }
                    }
                });
            },
            errorPlacement: function (error, element) { // 自定义提示错误位置
                $(".l_err").css('display', 'block');
                // element.css('border','3px solid #FFCCCC');
                $(".l_err").html(error.html());
            },
            success: function (label) { // 验证通过后
                $(".l_err").css('display', 'none');
            }
        });

        //MultipleUploader.init($('.system-upload-field-multiple'));
    });

    $("#name").blur(function(){
            var a=Math.random().toString(36).substr(2,4);
            var name =$("#name").val();
            var py=pinyin.getCamelChars(name+a);
            $("#code").val(py);
    });
</script>
</body>

</html>
